import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.util.Random;

public class BarWindow extends GraphWindow {
        
    public BarWindow(int numSlices) {
        super(numSlices);
    }
    
    // This method is called whenever the contents needs to be painted
    @Override
    public void paint(Graphics g){
    	Rectangle area = getBounds();
    	for (int i = 0; i < slices.length; i++) {
    		g.setColor(slices[i].color);
            g.fillRect(i * (area.width / slices.length), area.height - (int)(area.height * slices[i].value), (area.width / slices.length), (int)(area.height * slices[i].value));	
    	}
                
    }
    
    @Override
    public void calculate(String[] a, int top, DataProcessor dp) {
    	// some window to display bar chart, is it that much different then the pie chart??
        Random rand = new Random();
        System.out.println("Top " + top + " Words Bar:");
        // make a bar graph window instead of pie
        for (int i = 0; i < top; i++) {
       	 System.out.println(a[i] +" " + 100 * dp.pctTweetsWithWord(a[i])+ "%");
       	 // put random color in for bar chart word
            addSlice(dp.pctTweetsWithWord(a[i]), new Color(rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));
        }
    }
}
